package com.sky.controller.user;

import com.sky.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController("UserShopController")
@Api(tags = "店铺相关接口")
@RequestMapping("/user/shop")
public class ShopController {

    private final RedisTemplate<Object,Object> redisTemplate;
    private static final String KEY = "SHOP_STATUS";

    @Autowired
    public ShopController(RedisTemplate<Object,Object> redisTemplate) {
        this.redisTemplate = redisTemplate;
    }

    /**
     * 获取店铺状态
     * @return 店铺状态
     */
    @GetMapping("/status")
    @ApiOperation("获取店铺状态")
    public Result<Integer> getStatus(){
        Integer shopStatus = (Integer) redisTemplate.opsForValue().get(KEY);
        log.info("获取店铺状态: {}", shopStatus);
        return Result.success(shopStatus);
    }
}
